package gazzera.utils;
import java.math.*;
import java.security.*;
import java.security.cert.*;


public class SSLUtils
{
	private static MessageDigest m = null; 
	
	public static synchronized String getSha1Cert(java.security.cert.Certificate c) throws CertificateEncodingException, NoSuchAlgorithmException
	{
		if (m==null)
		{
			m = MessageDigest.getInstance("SHA1");
		}
		else
		{
		    m.reset();
		}
		byte[] cert = c.getEncoded();
		
		m.update(cert);
		String md5 = new BigInteger(1, m.digest()).toString(16);
		return md5.toLowerCase();
	}
}
